package per.chenxin.util.tcp.http;

import java.io.IOException;
import java.io.InputStream;
import java.net.ServerSocket;
import java.net.Socket;
import java.net.SocketTimeoutException;

public class TestServer {
	public static void main(String[] args) {
        ServerSocket serverSocket;
        InputStream inputClient = null;
        try {
            serverSocket = new ServerSocket(8080);
            serverSocket.setSoTimeout(1000);
            while (true) {
                try {
                    Socket socketClient = serverSocket.accept();
                    socketClient.setSoTimeout(1000);
                    
                    inputClient = socketClient.getInputStream();
                    byte[] buffer = HttpUtil.getBytesFromInputStream(inputClient);
                    
                    System.out.println(new String(buffer));
                    
                } catch (SocketTimeoutException sockettimeoutexception) {
                }
            }
        } catch (IOException e) {
            e.printStackTrace();
        }
	}
}
